<template>
  <div class="app-container" v-loading="pageLoading">
    <z-table :list="list" :tableProps="tableProps" :columns="columns">
    </z-table>
  </div>
</template>

<script>
import commonMixin from '@/views/_common/mixin'
export default {
  name: 'fileManage',
  mixins: [commonMixin],
  components: {},
  props: {
    basicInfoShow: {
      type: Boolean,
      default: true,
    },
    deviceId: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      query: {
        file_code: '',
        page: 1,
        size: 10,
      },
      name: '文件信息',
      api: this.$api.TpmEquipmentFile,
      postForList: true,
      tableProps: {
        border: true,
        opsColWith: 100,
        fixed: false,
        highlightCurrentRow: true,
        hideOperations: false,
      },
      columns: [
        { title: '文件编号', key: 'file_code' },
        { title: '文件名称', key: 'file_name' },
        { title: '修改人', key: 'modify_user', width: 100 },
        { title: '最后修改时间', key: 'modify_time', width: 100 },
      ],
    }
  },
  computed: {},
  watch: {
    basicInfoShow: {
      immediate: true,
      handler(val, old) {
        if (!val) {
          this.tableProps = {
            border: true,
            opsColWith: 160,
            fixed: false,
            highlightCurrentRow: true,
            hideOperations: true,
          }
          this.getdevicelist(this.deviceId)
        }
      },
    },
  },
  created() {},
  mounted() {},
  methods: {
    getdevicelist(id) {
      let data = {
        page: 1,
        size: 100,
        machine_id: id,
      }
      this.$request(this.api + 'GetTpmEquipmentFileByMachine', data, 'post').then((r) => {
        const { total, list } = r
        this.list = list
      })
    },
  },
}
</script>

<style lang="scss" scoped></style>